#!/bin/bash

#Usage: ./join_cluster.sh IP port TARGETIP port

# localhost:port will be added to TARGET:7400

#IP=$(ifconfig | grep -A 2 eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')

FROM_IP=$1
FROM_PORT=$2
TARGET=$3
TARGET_PORT=$4

./redis-trib.rb add-node --slave ${FROM_IP}:${FROM_PORT} ${TARGET}:${TARGET_PORT}


#for port in "$@"
#do
#	if [[ "${port}" == "$1" ]]
#	then
#		TARGET=$1
#	else
#		./redis-trib.rb add-node --slave ${IP}:${port} ${TARGET}:${DEFAULT_PORT}
#	fi
#done